﻿using System;
using EPiServer.Shell.WebForms;
using OpenWaves.EPiServer.GeoProperties;
using OpenWaves.Web;
using System.Web.UI;

[assembly: PublicAssemblyResources(AssemblyResources.LocationPageAssemblyResourceName)]

[assembly: PublicAssemblyResources(AssemblyResources.EPiServerUiMasterPageAssemblyResourceName)]

[assembly: WebResource(AssemblyResources.GeoPickerControlAssemblyResourceName, "text/javascript")]

namespace OpenWaves.EPiServer.GeoProperties
{
    public static partial class AssemblyResources
    {
        public const string LocationPageAssemblyResourceName = "OpenWaves.EPiServer.GeoProperties.LocationPage.aspx";

        public const string EPiServerUiMasterPageAssemblyResourceName = "OpenWaves.EPiServer.GeoProperties.EPiServerUI.Master";

        public const string GeoPickerControlAssemblyResourceName = "OpenWaves.EPiServer.GeoProperties.Scripts.GeoPickerControl.js";
    }

    public partial class LocationPage : WebFormsBase
    {               
        protected bool IsZoomVisible
        {
            get { return Convert.ToBoolean(Request.QueryString["showZoom"]); }
        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            var resourceUrl = this.Page.ClientScript.GetWebResourceUrl(typeof(LocationPage), AssemblyResources.GeoPickerControlAssemblyResourceName);
            this.Page.ClientScript.RegisterClientScriptInclude("GeoPickerControl", resourceUrl);
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            this.DataBind();
        }

        public override string Translate(string key)
        {
            return base.Translate(String.Format("/{0}/{1}", PropertyGeoPoint.UniqueName, key));
        }
    }
}